<%--
  Created by IntelliJ IDEA.
  User: zyh
  Date: 2021/11/18
  Time: 20:46
  To change this template use File | Settings | File Templates.
--%>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"
      integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"
        integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fm" uri="http://java.sun.com/jsp/jstl/fmt" %>
<style>
    th{
        text-align: center;
    }
</style>
<html>
<head>
    <title>Title</title>
</head>
<body>
<div class="container">
    <div class="row">
        <div class="col-md-10 col-md-offset-1">
        <table class="table table-bordered table-hover table-striped" style="text-align: center">
            <tr>
                <th  class="active">编号</th>
                <th class="success">姓名</th>
                <th class="active">性别</th>
                <th class="warning">工资</th>
                <th class="active">密码</th>
                <th class="danger">组号</th>
                <th class="active">出生日期</th>
                <th class="info" >电话</th>
                <th class="active">操作:<a href="${ctx}/addEmp.jsp" class="glyphicon glyphicon-plus"></a></th>
            </tr>
            <c:forEach items="${pageInfo.list}" var="i">
                <tr>
                    <td class="active">${i.eno}</td>
                    <td class="success">${i.ename}</td>
                    <td class="active">${i.esex}</td>
                    <td class="warning">${i.salary}</td>
                    <td class="active">${i.pwd}</td>
                    <td class="danger">${i.dno}</td>
                    <td class="active">
                        <fm:formatDate value="${i.date}" pattern="yyyy-MM-dd"/>
                    </td>
                    <td class="info">${i.phone}</td>
                    <td class="active">
                        <a href="${ctx}/emp/updateEmp?eno=${i.eno}">修改</a>
                        <button class="glyphicon glyphicon-remove del" ></button>
                    </td>
                </tr>
            </c:forEach>
            <tr>
                <td colspan="9">
                    <nav aria-label="Page navigation">
                        <ul class="pagination">
                            <li>
                                <a href="${ctx}/emp/index?pageIndex=${pageInfo.pageNum-1}" aria-label="Previous">
                                    <span aria-hidden="true">&laquo;</span>
                                </a>
                            </li>
                            <c:forEach items="${pageInfo.navigatepageNums}" var="i">
                                <li><a href="${ctx}/emp/index?pageIndex=${i}">${i}</a></li>
                            </c:forEach>
                            <li>
                                <a href="${ctx}/emp/index?pageIndex=${pageInfo.pageNum+1}" aria-label="Next">
                                        <span aria-hidden="true">&raquo;</span>
                                    </a>
                                </li>
                            </ul>
                        </nav>
                    </td>
                </tr>
            </table>
        </div>
    </div>
</div>

</body>
<script>
    $(function () {
        $(".del").click(function () {
            let c = $(this).parents("tr").children().first().text();
            if (confirm("是否删除")){
                location.href="${ctx}/emp/del?eno="+c;
            }
        })
    })
</script>
</html>
